﻿using System;
using System.Diagnostics;
using System.Reflection;
using Framework.Common;

namespace Framework.Common.Ioc
{
    public class TimeInterceptor : IInterceptor
    {
        public void Intercept(IInvocation invocation)
        {
            MethodBase method = invocation.GetConcreteMethod();
            string key = Formatter.Format(invocation.InvocationTarget, invocation.Args, method);
            Stopwatch sw = Stopwatch.StartNew();
            invocation.Proceed();
            sw.Stop();
            LogHelper.Debug("MethodName:" + key + "|ElapsedMilliseconds:" + sw.ElapsedMilliseconds);
        }
    }
}
